package day5;

import java.awt.*;

import javax.swing.*;

public class Eategg extends JFrame {

	private Image[] imgs;
	private static int index = 0;

	public Eategg() {
		imgs = new Image[14];
		Toolkit tool = Toolkit.getDefaultToolkit();
		for (int i = 0; i < 14; i++) {
			imgs[i] = tool.createImage("..\\src\\day5\\a" + (i + 1) + ".gif");

		}

		this.setSize(400, 300);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
		MyThread t1 = new MyThread();
		t1.start();
	}
	public void paint(Graphics g) {

		g.drawImage(imgs[index], 50, 50, this);
	}
	public static void main(String[] args) {
		new Eategg();
	}
	class MyThread extends Thread {

		public void run() {
			while (true) {

				index++;
				index = index % 14;

				try {
					sleep(100);
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				repaint();
			}

		}

	}

}
